package com.example.ymm.modules1.service.impl.ms;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.Slave;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ymm.base.BaseServiceImpl;
import com.example.ymm.model.TableList;
import com.example.ymm.model.YmPageDto;
import com.example.ymm.modules1.entity.ms.VSellClient;
import com.example.ymm.modules1.mapper.ms.VSellClientMapper;
import com.example.ymm.modules1.query.ms.VSellClientQueryCriteria;
import com.example.ymm.modules1.service.ms.VSellClientService;
import com.example.ymm.util.QueryHelpPlus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
@DS("slave")
public class VSellClientServiceImpl extends BaseServiceImpl<VSellClientMapper, VSellClient> implements VSellClientService {

    @Override
    public TableList<VSellClient> list(VSellClientQueryCriteria criteria, YmPageDto pageDto) {
        IPage<VSellClient> page = new Page<VSellClient>(pageDto.getPage(),pageDto.getPageSize());
        QueryWrapper predicate = QueryHelpPlus.getPredicate(VSellClient.class, criteria);
        baseMapper.selectPage(page, predicate);
        TableList<VSellClient> tableList=new TableList(page);
        return tableList;
    }

    public List<VSellClient> queryAll(VSellClientQueryCriteria criteria) {
        QueryWrapper predicate = QueryHelpPlus.getPredicate(VSellClient.class, criteria);
        List<VSellClient> result =baseMapper.selectList(predicate);
        return result;
    }
}
